package leetcode.tree;

/**
 * @author wangmaolin1
 * @date 2023/11/11 16:01
 */
public class _538 {
    int sum = 0;
    public TreeNode convertBST(TreeNode root) {
        track(root);
        return root;
    }
    public void  track(TreeNode root){
        if (root == null){
            return;
        }
        track(root.right);
        sum+=root.val;
        root.val=sum;
        track(root.left);
    }
}
